<template>
	<view class="goshop-help-container">
		<view class="goshop-list-wrap">
			<view class="goshop-list-item goshop-list-item-bottom" @tap="$Router.push({ path: '/pages/common/help/info', query: { id: item.id}})" v-for="(item,index) in helpDataList" :key="index">
				<view class="goshop-list-item-left">
					{{item.title}}
				</view>
				<view class="goshop-list-item-right">
					<view class="iconfont iconfont-right_arrow icon-bg-color"></view>
				</view>
			</view>
			<u-empty v-if="isEmpty === true && helpDataList.length === 0" :text="emptyText" mode="list"></u-empty>
			<u-loadmore
					:status="loadStatus" 
					:loading-text="loadingText" 
					:loadmore-text="loadmoreText" 
					:nomore-text="nomoreText" 
					loadingIcon="semicircle"
					@loadmore="getHelpPage"
				/>
		</view>
	</view>
</template>

<script>
	import {articlePage,articleInfo} from '@/common/http.api.js'
	export default {
		data() {
			return {
				//加载更多标志
				loadMoreFlag:false,
				isEmpty:false,
				goodDataList: [],
				loadStatus: 'loadmore',
				loadingText: '',
				loadmoreText: '',
				emptyText:'',
				nomoreText: '',
				helpDataList:[],
				params: {
					pageNo: 1,
					pageSize: 10,
				},
			};
		},
		onShow(){
		  this.refresh();	
		},
		onLoad(){
		  this.getHelpPage();	
		},
		methods:{
			refresh(){
				this.emptyText = this.$t('common.empty.text');
				this.loadingText = this.$t('common.loading.text');
				this.loadmoreText = this.$t('common.loadmore.text');
				this.nomoreText = this.$t('common.nomore.text');
			},
			getHelpPage(){
				this.loadStatus = 'loading';
				articlePage(this.params).then((res)=>{
					debugger
					uni.stopPullDownRefresh()
					if(res.code === 0){
					  if(res.data.list.length === 0){
						this.isEmpty = true;
						this.loadStatus = 'nomore'
						this.loadMoreFlag = false;
					  }else if (res.data.list.length < 10) {
						this.loadStatus = 'nomore'
						this.loadMoreFlag = false;
					  } else {
						this.params.pageNo++;
						this.loadStatus = 'loading'
						this.loadMoreFlag = true;
					  }
					  if (this.params.pageNo > 1) {
						this.helpDataList = this.helpDataList.concat(res.data.list);
					  } else {
						this.helpDataList = res.data.list;
					  }
					}
				  }).catch(error=>{
					console.error(error)
				  })
			}
		}
	}
</script>

<style lang="scss">
page{
	height: 100%;
}
.goshop-help-container{
	height: 100%;
	.goshop-list-wrap{
		height: 100%;
	}
}

</style>
